from selenium import webdriver
from selenium.webdriver.common.by import By

from web.app_page.app_page import AppPage


class MainPage:

    # 初始化driver：远程调试模式或者cookies
    def __init__(self):
        print(0000)
        # 声明chrome参数
        chrome_arg = webdriver.ChromeOptions()
        # 加入调试地址
        chrome_arg.debugger_address = '127.0.0.1:9222'
        self.driver = webdriver.Chrome(options=chrome_arg)
        # 隐式等待，网络加载缓存时间
        self.driver.implicitly_wait(5)
        print("111")

    def goto_app(self):
        print(2222)
        self.driver.find_element(By.XPATH, "//div[contains(text(), '应用列表')]").click()
        return AppPage(self.driver)

if __name__ == '__main__':
    mp = MainPage()
    mp.goto_app()